package com.itdct.onflow.system.common.config.file

import com.itdct.onflow.core.config.onflow.file.MinioConfig
import io.minio.MinioClient
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
 * @author Zhouwx
 * @date 2025/9/24 11:09:47
 * @version 1.0
 * @description
 */
@Configuration
@ConditionalOnProperty(name = ["onflow.file.container-type"], havingValue = "minio")
class MinioClientConfig(
    val minioConfig: MinioConfig
) {
    @Bean
    fun minioClient(): MinioClient {
        return MinioClient.builder()
            .endpoint(minioConfig.endpoint)
            .credentials(minioConfig.accessKey, minioConfig.secretKey)
            .build()
    }

}